package com.jay.beiange.efccp;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by Administrator on 2016/12/25 0025.
 */

public class AboutActivity extends Activity {

    private Toolbar mToolbar;
    private TextView mToolbarTitle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about);
        initView();
        initEvent();
        initData();
    }



    private void initView() {
        mToolbar = (Toolbar) findViewById(R.id.id_toolbar);
        mToolbarTitle = (TextView) mToolbar.findViewById(R.id.id_toolbar_title);

    }
    private void initEvent() {
        mToolbarTitle.setText("关于我们");
        mToolbar.setNavigationIcon(R.mipmap.left_arrow);
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }

    private void initData() {
        OkHttpClient mOkHttpClient = new OkHttpClient();
        final Request request = new Request.Builder()
                .url("http://192.168.22.151/app_dev.php/open/about")
                .build();
        Call call = mOkHttpClient.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                e.getMessage();
                call.request();

               runOnUiThread(new Runnable() {
                   @Override
                   public void run() {
                      Toast.makeText(getBaseContext(),  "Update My UI",
                              Toast.LENGTH_LONG).show();
                       Log.v("aaa","状态码：dsadsada");
                   }
               });




            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                final String res = response.body().string();
                if(response.code() ==200){
                    Log.v("aaa","状态码："+response.isSuccessful()+"");
                }


            }
        });

    }



}
